home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / ppageautosave.rexx < prev    next >
OS/2 REXX Batch file  |  1993-02-15  |  2KB  |  132 lines

  1. /*
  2.     PPageAutoSave.rexx
  3.     Copyright Gold Disk Inc, January, 1993
  4. */
  5. signal on break_c
  6. signal on break_d
  7. signal on break_e
  8. signal on break_f
  9. signal on error
  10. signal on halt
  11. signal on ioerr
  12.  
  13. arg backup
  14.  
  15. if ~show(p, 'PPAGEAREXX') then exit_msg()
  16.  
  17. if ~show(l, "rexxsupport.library") then
  18.     if ~addlib("rexxsupport.library",0,-30) then
  19.    call exit_msg("Please install the rexxsupport.library in your libs: directory before running this Genie")
  20.  
  21. minutes = 60 * 50
  22.  
  23. do forever
  24.  
  25.     interval = getclip(ppautosave)
  26.     if interval = '' then exit_msg()
  27.  
  28.     call delay(interval * minutes)
  29.  
  30.     if ~show(p, 'PPAGEAREXX') then exit_msg()
  31.  
  32.     do while ppm_GetState() ~= "0 0"
  33.       call delay(.2 * minutes)
  34.     end
  35.  
  36.     if ~ppm_DocChanged() then iterate
  37.  
  38.     dname   = ppm_GetDocName()
  39.     dsaved  = ppm_SavedDate()
  40.  
  41.     if dname ~= prevdname then
  42.     do
  43.         ok =  ppm_Inform(3, "Would you like to save now?", "Cancel","No", "Yes")
  44.  
  45.         if ok = 1 then iterate
  46.         else if ok = 0 then exit_msg()
  47.  
  48.         if dsaved = "Not Saved" then
  49.         do
  50.             dname = ppm_GetFileName("Save Document As..", "", "")
  51.             if dname = '' then iterate
  52.         end
  53.  
  54.         backup = Y
  55.         file = splitpath(dname)
  56.         prevdname = dname
  57.  
  58.     end
  59.     else
  60.     do
  61.         ok =  ppm_Inform(3, "Would you like to save now?", "Cancel","No", "Yes")
  62.         if ok = 1 then iterate
  63.         else if ok = 0 then exit_msg()
  64.     end
  65.     
  66.     if backup = 'Y' & exists(dname) then
  67.     do
  68.         address command
  69.         'copy ' || '"' || dname || '" ' || '"' || dname || '.bak"'
  70.         backup = N
  71.     end
  72.  
  73.     if ~ppm_SaveDocument(dname) then
  74.     do
  75.         response =  ppm_Inform(2, "An error has occured saving document. Try again?", "No", "Yes")
  76.         if response = 0 then exit_msg()
  77.         else iterate
  78.     end
  79.  
  80.     call ppm_SetDocName(file)
  81. end
  82.  
  83.  
  84. exit_msg()
  85.  
  86. splitpath: procedure expose dname
  87. do
  88.  
  89.     spos = lastpos('/', dname)
  90.     vpos = 0
  91.  
  92.     if spos = 0 then
  93.     do
  94.        vpos = pos(':', dname)
  95.        if vpos = 0 & spos = 0 then
  96.        return dname
  97.  
  98.     end
  99.  
  100.     file    = strip(substr(dname, max(vpos, spos) + 1))
  101.  
  102.     return(file)
  103.  
  104. end
  105.  
  106. exit_msg: procedure
  107. do
  108.     parse arg message
  109.  
  110.     if message ~= '' then
  111.       call ppm_Inform(1, message, )
  112.  
  113.     call setclip(ppautosave, "")
  114.  
  115.     exit
  116.  
  117. end
  118.  
  119. break_c:
  120. break_d:
  121. break_e:
  122. break_f:
  123. error:
  124. say errortext(rc)
  125. halt:
  126. ioerr:
  127. do
  128.     call setclip(ppautosave, "")
  129.     exit
  130. end
  131.  
  132.